export function throttle<Return, Args extends any[]>(
  fn: (...args: Args) => Return,
  delay: number = 100,
): (...args: Args) => Return | undefined {
  let wait = false

  return (...args: Args) => {
    if (wait)
      return undefined

    const val = fn(...args)

    wait = true

    window.setTimeout(() => {
      wait = false
    }, delay)

    return val
  }
}
